/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import controller.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

import model.Contato;

/**
 *
 * @author Andreia
 */
public class GravarContatoAction extends ContatoAction {

    public void GravarContatoAction() {
    }

    public void execute(HttpServletRequest request, HttpServletResponse response, String id)
            throws ServletException, IOException {
        Contato cont = new Contato();

        try {
           //{
            
            cont.setCodigo(Integer.parseInt(request.getParameter("codigo")));
            cont.setNome(request.getParameter("nome"));
            cont.setEmail(request.getParameter("email"));

            
            cnn.GravarContato(cont);
            

            RequestDispatcher rd = null;
            rd = request.getRequestDispatcher("index.jsp");
            rd.forward(request, response);
           // }
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServletException(e);
        }

    }

   
}